﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace unTroublemaker.Tests
{
    [TestClass]
    public class SpecificationTests
    {
        public TestContext TestContext { get; set; }

        [TestMethod, TestCategory("UnitTest")]
        public void GivenANonExistingFileThenFails()
        {
            var specification = new Specification("does not exist");
            Assert.IsFalse(specification.Valid);
        }

        [TestMethod, TestCategory("UnitTest")]
        public void GivenSimpleSpecificationCanCreateModel()
        {
            const string simpleSpecification = @"<specification>
    <check-registry key=""HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesPath"" value=""%ProgramFiles%""/>
</specification>";
            var resourceName = Resource.SaveFor(TestContext, simpleSpecification);
            var specification = new Specification(resourceName);

            Assert.IsTrue(specification.Valid, "Error in spec: " + specification.Error);
            Assert.AreEqual(1, specification.Items.Length);
        }
    }
}
